package com.controller;

import com.model.pojo.Commodity;
import com.service.ICommodityService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class Commoditycontroller {
    @Resource
    private ICommodityService iCommodityService;
    @RequestMapping("/addcommodity")
    public String addcommodity(Commodity commodity){
        iCommodityService.addCom(commodity);
        System.out.println(commodity);
        return "success";
    }
    @RequestMapping("/selectall")
    public String select(Commodity commodity, Model model){
        List<Commodity> list=iCommodityService.selectbyname(commodity);
        model.addAttribute("list",list);
        return "select";
    }
    @RequestMapping("/selecter")
    public String select(){

        return "select";
    }
    @RequestMapping("/addall")
    public String add(){
        return "add";
    }

    @RequestMapping("/delbyid")
    public String del(Commodity commodity){
        iCommodityService.delbyid(commodity);
        return "redirect:/selectall";
    }
}
